package com.service;

import com.Dao.RemarkDao;
import com.bean.Remark;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

public class RemarkService {
    RemarkDao dao=new RemarkDao();

    //添加
    public void addremark(Remark remark){
        try {
            dao.addRemark(remark);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
            System.out.println("添加评论失败！！！");
        }
    }
    //删除
    public  void deleteremark(int id){
        try {
            dao.deleteRemark(id);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
            System.out.println("删除评论失败！！！");
        }
    }
    //查看所有
    public List<Remark> getAllremark(){
        List<Remark> remarks=null;
        try {
             remarks= dao.getAllRemark();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
            System.out.println("查看失败！！！");
        }
         return remarks;
    }

    //查看单篇
    public List getSingleRemark(int articleId) throws SQLException {
        return dao.queryRemark(articleId);
    }

    //查询评论的数量
    public int findAllCount(int articleId) throws SQLException {
        return dao.findAllCount(articleId);
    }
    //获取发表时间
    public Date findPubTime(String content) throws SQLException {
        return dao.findPubTime(content);
    }

}
